package com.proba.annotations.hibernate;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import com.proba.annotations.TipPartnerDAO;
import com.proba.annotations.pojo.TipPartner;

public class TipPartnerHibernateDAO extends
		AbstractHibernateDAO<TipPartner, Long> implements
		TipPartnerDAO {

	public List<TipPartner> findByTipPartner(String tipPartner) {
		return findByCriteria(Restrictions.eq("tipPartner", tipPartner));
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<TipPartner> findByFilterParams(int startIndex, int pageSize,
			Long id, String tipPartner) {
		Criteria crit = getCriteria(startIndex, pageSize);
		if (id != null) {
			crit.add(Restrictions.eq("id", id));
			return crit.list();
		}
		if (tipPartner != null && !tipPartner.isEmpty()) {
			crit.add(like("tipPartner", tipPartner));
		}
		return crit.list();
	}
	

}
